package com.youlu.campus.service.activity;

import com.youlu.campus.base.exception.BusinessException;
import com.youlu.campus.entity.ActivityInfo;
import com.youlu.campus.entity.ActivityOrganizerInfo;
import com.youlu.campus.entity.ActivityQaInfo;
import com.youlu.campus.entity.ActivityRewardRule;
import com.youlu.campus.entity.ActivityTaskInfo;
import com.youlu.campus.entity.PayConfigPage;
import com.youlu.campus.service.ranking.entity.UserActivityPointRanking;
import com.youlu.campus.entity.UserPO;
import com.youlu.campus.entity.UserParticipateActivityInfo;
import com.youlu.campus.entity.UserQaInfo;
import com.youlu.campus.entity.UserQaLevel;
import com.youlu.campus.entity.VO.res.ActivityDetailH5Res;
import com.youlu.campus.entity.VO.res.H5UserCheckJoinActivityRes;
import com.youlu.campus.entity.VO.res.UserH5ActivityDetailScheduleRes;
import com.youlu.campus.entity.VO.res.UserOrganizerRes;
import com.youlu.campus.entity.domain.ActivityTaskDataDomain;
import com.youlu.campus.entity.english.vo.response.CompetitionUserInviteResponse;
import com.youlu.campus.entity.enums.TaskBizType;
import com.youlu.campus.service.activity.impl.ActivityPayConfigService;
import com.youlu.campus.service.contest.QQMiniContestService;
import com.youlu.campus.service.english.CompetitionUserInviteService;
import com.youlu.campus.service.invite.UserInviteRecordService;
import com.youlu.campus.service.platform.PlatformConfigService;
import com.youlu.campus.service.qa.ActivityQaInfoService;
import com.youlu.campus.service.qa.UserQaInfoService;
import com.youlu.campus.service.ranking.UserActivityPointRankingService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.Objects;

@Slf4j
@Service
public class ActivityH5PlusService {

    @Autowired
    private ActivityService activityService;

    @Autowired
    private UserParticipateActivityInfoService userParticipateActivityInfoService;

    @Autowired
    private QQMiniContestService qqMiniContestService;

    @Autowired
    private ActivityTaskService activityTaskService;

    @Autowired
    private CompetitionUserInviteService competitionUserInviteService;

    @Autowired
    private UserActivityPointRankingService userActivityPointRankingService;

    @Autowired
    private UserInviteRecordService userInviteRecordService;

    @Autowired
    private UserQaInfoService userQaInfoService;

    @Autowired
    private ActivityQaInfoService activityQaInfoService;

    @Autowired
    private MongoTemplate mongoTemplate;

    @Autowired
    private ActivityRewardRuleService activityRewardRuleService;

    @Autowired
    private ActivityPayConfigService activityPayConfigService;

    @Autowired
    private PlatformConfigService platformConfigService;

    /**
     * H5活动用户活动详情进度
     *
     * @param currentUser
     * @param activityId
     * @return
     */
    public UserH5ActivityDetailScheduleRes findActivityDetailSchedule(UserPO currentUser, String activityId) {
        ActivityInfo activityInfo = activityService.findOne(activityId);
        UserH5ActivityDetailScheduleRes userH5ActivityDetailSchedule = new UserH5ActivityDetailScheduleRes();
        userH5ActivityDetailSchedule.setNickName(currentUser.getNickName());
        userH5ActivityDetailSchedule.setAvatarUrl(currentUser.getAvatarUrl());
        userH5ActivityDetailSchedule.setStatus(qqMiniContestService.getActivityStatus(activityInfo.getEndTime()));
        userH5ActivityDetailSchedule.setEnableLottery(activityInfo.getEnableLottery());
        userH5ActivityDetailSchedule.setRewardValueAlias(activityInfo.getRewardValueAlias());
        userH5ActivityDetailSchedule.setAfterSignUpDetail(activityInfo.getAfterSignUpDetail());
        userH5ActivityDetailSchedule.setCountryRankName(activityInfo.getCountryRankName());
        userH5ActivityDetailSchedule.setProvinceRankName(activityInfo.getProvinceRankName());
        userH5ActivityDetailSchedule.setCsInfos(activityInfo.getCsInfos());
        userH5ActivityDetailSchedule.setThemeColor(activityInfo.getThemeColor());
        userH5ActivityDetailSchedule.setActivityType(activityInfo.getType());
        userH5ActivityDetailSchedule.setHasCountryRank(activityInfo.getHasCountryRank());
        userH5ActivityDetailSchedule.setHasProvinceRank(activityInfo.getHasProvinceRank());
        userH5ActivityDetailSchedule.setHasUniversityRank(activityInfo.getHasUniversityRank());
        userH5ActivityDetailSchedule.setUniversityRankName(activityInfo.getUniversityRankName());
        userH5ActivityDetailSchedule.setStop(activityInfo.getStop());
        userH5ActivityDetailSchedule.setStopDetail(activityInfo.getStopDetail());
        userH5ActivityDetailSchedule.setHasMultiQa(activityInfo.getHasMultiQa());
        userH5ActivityDetailSchedule.setNotice(activityInfo.getNotice());
        userH5ActivityDetailSchedule.setNoticeContent(activityInfo.getNoticeContent());
        userH5ActivityDetailSchedule.setNoticeContentColor(activityInfo.getNoticeContentColor());
        userH5ActivityDetailSchedule.setHasOrgRank(activityInfo.getHasOrgRank());
        userH5ActivityDetailSchedule.setOrgRankName(activityInfo.getOrgRankName());
        userH5ActivityDetailSchedule.setColorValueInvite(activityInfo.getColorValueInvite());
        userH5ActivityDetailSchedule.setColorValueMenu(activityInfo.getColorValueMenu());
        userH5ActivityDetailSchedule.setColorValueUserInfo(activityInfo.getColorValueUserInfo());
        userH5ActivityDetailSchedule.setAfterSignUpSecondDetail(activityInfo.getAfterSignUpSecondDetail());
        userH5ActivityDetailSchedule.setCountryRankSubTile(activityInfo.getCountryRankSubTile());
        userH5ActivityDetailSchedule.setProvinceSubTile(activityInfo.getProvinceSubTile());
        userH5ActivityDetailSchedule.setUpdateUserSignUp(activityInfo.getUpdateUserSignUp());
        userH5ActivityDetailSchedule.setShowScheduleTips(activityInfo.getShowScheduleTips());
        userH5ActivityDetailSchedule.setAfterSignUpCsDetail(activityInfo.getAfterSignUpCsDetail());
        userH5ActivityDetailSchedule.setBeforeSignUpDetail(activityInfo.getBeforeSignUpDetail());
        userH5ActivityDetailSchedule.setAboutActivityDesc(activityInfo.getAboutActivityDesc());
        userH5ActivityDetailSchedule.setHideEndTime(activityInfo.getHideEndTime());
        userH5ActivityDetailSchedule.setStartTime(activityInfo.getStartTime());
        userH5ActivityDetailSchedule.setEndTime(activityInfo.getEndTime());
        userH5ActivityDetailSchedule.setBackgroundMusic(activityInfo.getBackgroundMusic());
        userH5ActivityDetailSchedule.setBackgroundMusicFileUrl(activityInfo.getBackgroundMusicFileUrl());
        userH5ActivityDetailSchedule.setDefaultPlayBackgroundMusic(activityInfo.getDefaultPlayBackgroundMusic());
        userH5ActivityDetailSchedule.setCertificateReceivePic(activityInfo.getCertificateReceivePic());
        userH5ActivityDetailSchedule.setOpenMiniJumpLink(activityInfo.getOpenMiniJumpLink());
        userH5ActivityDetailSchedule.setMiniJumpLink(activityInfo.getMiniJumpLink());
        userH5ActivityDetailSchedule.setMiniJumpLinkTextDesc(activityInfo.getMiniJumpLinkTextDesc());
        userH5ActivityDetailSchedule.setInvitePopupBackgroundImgUrl(activityInfo.getInvitePopupBackgroundImgUrl());
        userH5ActivityDetailSchedule.setInvitePopupButtonImgUrl(activityInfo.getInvitePopupButtonImgUrl());
        userH5ActivityDetailSchedule.setH5SchedulePopupTips(activityInfo.getH5SchedulePopupTips());
        userH5ActivityDetailSchedule.setQaPassTips(activityInfo.getQaPassTips());
        userH5ActivityDetailSchedule.setQaNotPassTips(activityInfo.getQaNotPassTips());
        Date now = new Date();
        if (Objects.nonNull(activityInfo.getRecieveRewardStartTime()) && Objects.nonNull(activityInfo.getRecieveRewardEndTime())) {
            if (now.after(activityInfo.getRecieveRewardStartTime()) && now.before(activityInfo.getRecieveRewardEndTime())) {
                PayConfigPage payConfigPage = activityPayConfigService.findByActivityId(activityInfo.getId(), 0);
                userH5ActivityDetailSchedule.setWechatPayUrl(platformConfigService.getBizFrontPayDomain() + platformConfigService.getPayCatalogue() + String.format(ActivityPayConfigService.activityPayUrl, activityInfo.getId(), activityInfo.getThemeColor(), payConfigPage.getAppId()));
            }
        }
        //获取邀请任务信息
        String backGroundImageUrl = "";
        ActivityTaskInfo activityTaskInfo = activityTaskService.find(activityId, TaskBizType.INVITE);
        if (Objects.nonNull(activityTaskInfo)) {
            userH5ActivityDetailSchedule.setInviteValue(activityTaskInfo.getRatio().intValue());
            userH5ActivityDetailSchedule.setShareInviteButtonType(activityTaskInfo.getShareInviteButtonType());
            userH5ActivityDetailSchedule.setTaskId(activityTaskInfo.getId());
            userH5ActivityDetailSchedule.setShareInviteButtonBackGroundImgUrl(activityTaskInfo.getShareInviteButtonBackGroundImgUrl());
            userH5ActivityDetailSchedule.setInviteButtonTips(activityTaskInfo.getInviteButtonTips());
            userH5ActivityDetailSchedule.setSignUpInviteTimeLimitTextTips(activityTaskInfo.getInviteLimitTips());
            userH5ActivityDetailSchedule.setInviteBackGroundImageUrl(activityTaskInfo.getInviteBackGroundImageUrl());
            userH5ActivityDetailSchedule.setInviteSubTips(activityTaskInfo.getSubTips());
            userH5ActivityDetailSchedule.setCertificateVolunteerName(activityTaskInfo.getCaDisplay());
            userH5ActivityDetailSchedule.setQuantityDisplay(activityTaskInfo.getQuantityDisplay());
            backGroundImageUrl = activityTaskInfo.getBackGroundImageUrl();
            userH5ActivityDetailSchedule.setDetail(activityTaskInfo.getDetail());
        }
        //获取用户报名信息
        UserParticipateActivityInfo userParticipateActivityInfo =
                userParticipateActivityInfoService.findByUserIdActivityId(currentUser.getId(), activityId);
        if (Objects.nonNull(userParticipateActivityInfo)) {
            userH5ActivityDetailSchedule.setJoined(Boolean.TRUE);
            userH5ActivityDetailSchedule.setUniversityId(userParticipateActivityInfo.getUniversityId());
            userH5ActivityDetailSchedule.setUniversityName(userParticipateActivityInfo.getUniversityName());
            Date signUpTime = userParticipateActivityInfo.getSignUpTime();
            if (Objects.nonNull(signUpTime)) {
                //根据用户报名时间增加1小时
                LocalDateTime signUpTimeLocal = LocalDateTime.ofInstant(signUpTime.toInstant(), ZoneId.systemDefault());
                LocalDateTime localDateTime = signUpTimeLocal.plusHours(1);
                //如果当前时间大于报名时间一个小时
                if (LocalDateTime.now().isBefore(localDateTime)) {
                    userH5ActivityDetailSchedule.setSignUpInviteTimeLimit(Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()).getTime());
                    userH5ActivityDetailSchedule.setSignUpInviteTimeLimitTips(Boolean.TRUE);
                }
            }


        }
        //获取荣誉证书信息
        ActivityTaskInfo taskInfoQA = activityTaskService.find(activityId, TaskBizType.QA);
        if (Objects.nonNull(taskInfoQA)) {
            userH5ActivityDetailSchedule.setQaTips(taskInfoQA.getSubTips());
            userH5ActivityDetailSchedule.setQaButtonText(taskInfoQA.getButtonName());
            userH5ActivityDetailSchedule.setCertificateHonorName(taskInfoQA.getCaDisplay());
            //获取答题信息
            ActivityQaInfo activityQaInfo = activityQaInfoService.findByActivityIdAndQaNumber(activityId, 3);
            if (Objects.nonNull(activityQaInfo)) {
                userH5ActivityDetailSchedule.setQaInfoId(activityQaInfo.getId());
                UserQaInfo userQaInfo = userQaInfoService.findByUserIdAndQaInfoIdAndActivityId(currentUser.getId(),
                        activityQaInfo.getId(), activityId);
                //判断用户答题是否已用完
                if (Objects.nonNull(userQaInfo)) {
                    if (CollectionUtils.isNotEmpty(userQaInfo.getUserQaLevelList())) {
                        //获取答题等级
                        UserQaLevel userQaLevel =
                                userQaInfo.getUserQaLevelList().stream().max(Comparator.comparing(UserQaLevel::getQsScore)).orElse(null);
                        if (Objects.nonNull(userQaLevel)) {
                            userH5ActivityDetailSchedule.setCertificateHonorLevel(userQaLevel.getLevel());
                            userH5ActivityDetailSchedule.setQaTaskFinish(userQaLevel.getHighestLevel());
                            userH5ActivityDetailSchedule.setBackGroundImageUrl(taskInfoQA.getNotCanBackGroundImage());
                        }
                    }
                    if (userQaInfo.getReTryQaNum() >= activityQaInfo.getTotalQaNum()) {
                        userH5ActivityDetailSchedule.setBackGroundImageUrl(taskInfoQA.getNotCanBackGroundImage());
                        userH5ActivityDetailSchedule.setQaTaskFinish(Boolean.TRUE);
                    } else {
                        if (!userH5ActivityDetailSchedule.getQaTaskFinish()) {
                            userH5ActivityDetailSchedule.setBackGroundImageUrl(taskInfoQA.getCanBackGroundImage());
                        }
                    }
                } else {
                    userH5ActivityDetailSchedule.setBackGroundImageUrl(taskInfoQA.getCanBackGroundImage());
                }

            } else {
                userH5ActivityDetailSchedule.setBackGroundImageUrl(backGroundImageUrl);
            }
        } else {
            userH5ActivityDetailSchedule.setBackGroundImageUrl(backGroundImageUrl);
        }
        //获取活力值
        UserActivityPointRanking userActivityPointRanking =
                userActivityPointRankingService.findByUserIdAndActivityId(currentUser.getId(), activityId);
        if (Objects.nonNull(userActivityPointRanking)) {
            userH5ActivityDetailSchedule.setRewardValue(userActivityPointRanking.getQuantity().intValue());
        }
        CompetitionUserInviteResponse competitionUserInvite = new CompetitionUserInviteResponse();
        competitionUserInvite.setInviteValue(userH5ActivityDetailSchedule.getRewardValue());
        competitionUserInviteService.matchRule(activityTaskInfo, activityId, competitionUserInvite);
        userH5ActivityDetailSchedule.setRate(competitionUserInvite.getRate());
        userH5ActivityDetailSchedule.setTips(competitionUserInvite.getTips());
        userH5ActivityDetailSchedule.setCertificateVolunteerLevel(competitionUserInvite.getCaLevel());
        int inviteCount = userInviteRecordService.getInviteUserCount(currentUser.getId(), activityId,
                activityTaskInfo.getId(), Boolean.TRUE).intValue();
        userH5ActivityDetailSchedule.setInviteCount(inviteCount);
        //是否存在承办单位
        ActivityTaskInfo organizerTaskInfo = activityTaskService.find(activityId, TaskBizType.ORGANIZER);
        if (!activityInfo.getHasOrganizer() || Objects.isNull(organizerTaskInfo)) {
            return userH5ActivityDetailSchedule;
        }
        UserOrganizerRes organizer = new UserOrganizerRes();
        organizer.setShareInviteButtonType(organizerTaskInfo.getShareInviteButtonType());
        organizer.setTaskId(organizerTaskInfo.getId());
        organizer.setShareInviteButtonBackGroundImgUrl(organizerTaskInfo.getShareInviteButtonBackGroundImgUrl());
        organizer.setInviteButtonTips(organizerTaskInfo.getInviteButtonTips());
        organizer.setDetail(organizerTaskInfo.getDetail());
        organizer.setBackGroundImageUrl(organizerTaskInfo.getBackGroundImageUrl());
        organizer.setTips(organizerTaskInfo.getH5Tips());
        if (StringUtils.isNotBlank(organizerTaskInfo.getTaskAlias())) {
            organizer.setTaskAlias(organizerTaskInfo.getTaskAlias());
        }
        organizer.setTaskPendAuditImgUrl(organizerTaskInfo.getTaskPendAuditImgUrl());
        organizer.setTaskPassAuditImgUrl(organizerTaskInfo.getTaskPassAuditImgUrl());
        organizer.setOrganizerCsUrl(activityInfo.getOrganizerCsUrl());
        Query query = new Query().addCriteria(Criteria.where("ownerUserId").is(currentUser.getId()).and("activityId").is(activityId));
        ActivityOrganizerInfo userOrganizerInfo = this.mongoTemplate.findOne(query, ActivityOrganizerInfo.class);
        if (Objects.isNull(userOrganizerInfo)) {
            log.info("【承办单位】当前用户- > {}参加活动-> {}未申请承办单位", currentUser.getId(), activityId);
            userH5ActivityDetailSchedule.setOrganizer(organizer);
            return userH5ActivityDetailSchedule;
        }
        organizer.setStatus(userOrganizerInfo.getStatus());
        organizer.setOrganizerName(userOrganizerInfo.getName());
        //获取承办单位贡献值
        Double q = activityService.getOrgQByOrgIds(activityId, organizerTaskInfo.getId(), Arrays.asList(userOrganizerInfo.getId()));
        ActivityRewardRule orgActivityRewardRule = new ActivityRewardRule();
        orgActivityRewardRule.setQaStatus(true);
        orgActivityRewardRule.setOffLineStatus(true);
        orgActivityRewardRule.setActivityId(activityId);
        orgActivityRewardRule.setTaskId(userOrganizerInfo.getId());
        orgActivityRewardRule.setToMatchValue(q);
        ActivityRewardRule rule = activityRewardRuleService.match(activityId, organizerTaskInfo.getId(), Boolean.FALSE, Boolean.FALSE, orgActivityRewardRule);
        ActivityTaskDataDomain taskDataDomain = activityService.getTaskDataDomain(organizerTaskInfo, currentUser.getId(), rule, Arrays.asList(currentUser.getId()));
        organizer.setCaName(taskDataDomain.getCaName());
        organizer.setInviteCount(taskDataDomain.getInviteNum());
        organizer.setRate(taskDataDomain.getRate());
        organizer.setRateTips(taskDataDomain.getRateTips());
        organizer.setOrderNo(taskDataDomain.getOrderNo());
        organizer.setOrderStr(taskDataDomain.getOrderStr());
        organizer.setQ(taskDataDomain.getQ().intValue());
        organizer.setQStr(taskDataDomain.getQStr());

        userH5ActivityDetailSchedule.setOrganizer(organizer);
        return userH5ActivityDetailSchedule;
    }


    public ActivityDetailH5Res activityDetailByActivityId(String activityId) {
        ActivityDetailH5Res activityDetailH5Res = new ActivityDetailH5Res();
        ActivityInfo activityInfo = activityService.findOne(activityId);
        activityDetailH5Res.setProvinceRankName(activityInfo.getProvinceRankName());
        activityDetailH5Res.setCountryRankName(activityInfo.getCountryRankName());
        activityDetailH5Res.setAfterSignUpDetail(activityInfo.getAfterSignUpDetail());
        activityDetailH5Res.setBeforeSignUpDetail(activityInfo.getBeforeSignUpDetail());
        activityDetailH5Res.setDetail(activityInfo.getDetail());
        activityDetailH5Res.setHeaderImageUrl(activityInfo.getHeaderImageUrl());
        activityDetailH5Res.setHeaderHeight(activityInfo.getHeaderHeight());
        activityDetailH5Res.setHeaderImageMode(activityInfo.getHeaderImageMode());
        activityDetailH5Res.setCsInfos(activityInfo.getCsInfos());
        activityDetailH5Res.setHasCountryRank(activityInfo.getHasCountryRank());
        activityDetailH5Res.setHasProvinceRank(activityInfo.getHasProvinceRank());
        activityDetailH5Res.setHasUniversityRank(activityInfo.getHasUniversityRank());
        activityDetailH5Res.setStop(activityInfo.getStop());
        activityDetailH5Res.setUniversityRankName(activityInfo.getUniversityRankName());
        activityDetailH5Res.setStopDetail(activityInfo.getStopDetail());
        activityDetailH5Res.setHasMultiQa(activityInfo.getHasMultiQa());
        activityDetailH5Res.setStatus(qqMiniContestService.getActivityStatus(activityInfo.getEndTime()));
        activityDetailH5Res.setThemeColor(activityInfo.getThemeColor());
        activityDetailH5Res.setActivityType(activityInfo.getType());
        activityDetailH5Res.setColorValueInvite(activityInfo.getColorValueInvite());
        activityDetailH5Res.setColorValueMenu(activityInfo.getColorValueMenu());
        activityDetailH5Res.setColorValueUserInfo(activityInfo.getColorValueUserInfo());
        activityDetailH5Res.setAfterSignUpSecondDetail(activityInfo.getAfterSignUpSecondDetail());
        activityDetailH5Res.setCountryRankSubTile(activityInfo.getCountryRankSubTile());
        activityDetailH5Res.setProvinceSubTile(activityInfo.getProvinceSubTile());
        activityDetailH5Res.setHasOrgRank(activityInfo.getHasOrgRank());
        activityDetailH5Res.setOrgRankName(activityInfo.getOrgRankName());
        activityDetailH5Res.setChinaWebsite(activityInfo.getChinaWebsite());
        activityDetailH5Res.setShowScheduleTips(activityInfo.getShowScheduleTips());
        activityDetailH5Res.setH5OfficialQrcode(activityInfo.getH5OfficialQrcode());
        activityDetailH5Res.setBackgroundMusic(activityInfo.getBackgroundMusic());
        activityDetailH5Res.setDefaultPlayBackgroundMusic(activityInfo.getDefaultPlayBackgroundMusic());
        activityDetailH5Res.setBackgroundMusicFileUrl(activityInfo.getBackgroundMusicFileUrl());
        activityDetailH5Res.setOpenMiniJumpLink(activityInfo.getOpenMiniJumpLink());
        activityDetailH5Res.setMiniJumpLink(activityInfo.getMiniJumpLink());
        activityDetailH5Res.setMiniJumpLinkTextDesc(activityInfo.getMiniJumpLinkTextDesc());
        return activityDetailH5Res;
    }

    public ActivityDetailH5Res checkUserJoinActivity(UserPO currentUser, String activityId) {
        log.info("查询该用户-> {} 是否参与该活动- > {} ", currentUser.getId(), activityId);
        ActivityDetailH5Res activityDetailH5Res = this.activityDetailByActivityId(activityId);
        UserParticipateActivityInfo userParticipateActivityInfo =
                userParticipateActivityInfoService.findByUserIdActivityId(currentUser.getId(), activityId);
        if (Objects.isNull(userParticipateActivityInfo)) {
            return activityDetailH5Res;
        }
        if (userParticipateActivityInfo.getJoined()) {
            log.info("该用户-> {} 已参与该活动- > {} joined ", currentUser.getId(), activityId);
            activityDetailH5Res.setJoined(Boolean.TRUE);
        }
        return activityDetailH5Res;
    }

    public H5UserCheckJoinActivityRes checkH5UserJoinActivity(UserPO currentUser, String activityId) {
        log.info("查询该用户-> {} 是否参与该活动- > {} ", currentUser.getId(), activityId);
        ActivityInfo activityInfo = activityService.findOne(activityId);
        if (Objects.isNull(activityInfo)) {
            throw new BusinessException("当前活动不存在");
        }
        H5UserCheckJoinActivityRes h5UserCheckJoinActivity = new H5UserCheckJoinActivityRes();
        h5UserCheckJoinActivity.setStop(activityInfo.getStop());
        h5UserCheckJoinActivity.setStopDetail(activityInfo.getStopDetail());
        h5UserCheckJoinActivity.setStatus(qqMiniContestService.getActivityStatus(activityInfo.getEndTime()));
        h5UserCheckJoinActivity.setQaMode(activityInfo.getQaMode());
        UserParticipateActivityInfo userParticipateActivityInfo =
                userParticipateActivityInfoService.findByUserIdActivityId(currentUser.getId(), activityId);
        if (Objects.isNull(userParticipateActivityInfo)) {
            return h5UserCheckJoinActivity;
        }
        if (userParticipateActivityInfo.getJoined()) {
            log.info("该用户-> {} 已参与该活动- > {} joined ", currentUser.getId(), activityId);
            h5UserCheckJoinActivity.setJoined(Boolean.TRUE);
        }
        return h5UserCheckJoinActivity;
    }

}
